﻿@{
    ViewBag.Title = "用户管理";
    Layout = "~/Views/Shared/_LayoutInput.cshtml";
}
<form class="layui-form" action="" onsubmit="return false">
    <div class="mainBox">
        <div class="main-container">

            <input type="hidden" name="Id" v-model="Id" value="@ViewBag.Id" />
            <div class="layui-form-item">
                <label class="layui-form-label">密码框</label>
                <div class="layui-input-block">
                    <input type="password" name="newpwd" required lay-verify="required" placeholder="请输入密码框内容" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码框</label>
                <div class="layui-input-block">
                    <input type="password" name="newpwd1" required lay-verify="required" placeholder="请输入确认密码框" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'jquery'], function() {
        let form = layui.form;
        let $ = layui.jquery;
        form.on('submit(user-save)', function(data) {
            $.ajax({
                url: 'UpdPwd?Id='+data.field.Id+'&newpwd='+data.field.newpwd+"&newpwd1="+data.field.newpwd,
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function(result) {
                     if (result.Code == 200) {
                         layer.msg(result.Msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("user-table");
                        });

                }
                else
                {
                    layer.msg(result.Msg, {
                            icon: 2,
                            time: 1000
                        });
                }
                }
            })
            return false;
        });
    })
</script>
